package net.zdreamer.geracomium.adapter;

import java.util.List;

import net.zdreamer.geracomium.entity.GeracomiumInfos.GeracomiumInfo;
import net.zdreamer.geracomium.ui.home.GeracomiumDetailsActivity;
import net.zdreamer.geracomium.utils.tools_utils.ViewHolder;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.geracomium.R;

public class GeracomiumListAdapter extends MyBaseAdapter<GeracomiumInfo>
        implements OnClickListener {
    public GeracomiumListAdapter(Context context, List<GeracomiumInfo> list,
                                 int res) {
        super(context, list, res);
    }

    @Override
    protected View getView(int position, View convertView, ViewGroup parent,
                           GeracomiumInfo value) {
        if (convertView == null) {
            convertView = LayoutInflater.from(getmContext()).inflate(
                    R.layout.list_geracomium_detail, parent, false);
        }
      //  AssessService.makeHTTPrequest(getmContext(), URLTools.AssessUrl,handler);


        TextView geracomiumName = ViewHolder.get(convertView,
                R.id.geracomiium_name);
        TextView geracomiumArea = ViewHolder.get(convertView,
                R.id.geracomiium_area);
        ImageView geracomiumPicture = ViewHolder.get(convertView,
                R.id.geracomium_picture);
        geracomiumPicture.setOnClickListener(this);
        TextView geracomiumDetail_Text = ViewHolder.get(convertView,
                R.id.geracomium_detail_text);
        geracomiumDetail_Text.setOnClickListener(this);
        ImageView geracomiumReserve = ViewHolder.get(convertView,
                R.id.geracomium_reserve);
        geracomiumReserve.setOnClickListener(this);
        geracomiumName.setText(value.name);
        geracomiumArea.setText(value.area);
        geracomiumPicture.setImageResource(R.drawable.header_homepage);
        geracomiumDetail_Text.setText(value.detail);
        geracomiumReserve.setImageResource(R.drawable.reverse);
        return convertView;
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(getmContext(),
                GeracomiumDetailsActivity.class);
        // System.out.println(BaseApplication.get().getToken());


        getmContext().startActivity(intent);
    }

//    Handler handler = new Handler() {
//        @Override
//        public void handleMessage(android.os.Message msg) {
//            switch (msg.arg1) {
//                case 0:
//                    geracomiumDetail_Text.setText(msg.obj.toString());
//                    break;
//                default:
//                    break;
//            }
//
//            // System.out.println(msg.objg);
//        }
//    };

}
